From 45138b4b051b0c0ade6d0e392bf4f0262864f6e7 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Sun, 13 May 2007 10:04:34 +0100 Subject: [PATCH] hvm qemu: Fix for masking 64-bit operands broke 32-bit operands with 32-bit qemu. Issue spotted and initial fix provided by Dexuan Cui. Signed-off-by: Keir Fraser --- tools/ioemu/target-i386-dm/helper2.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/ioemu/target-i386-dm/helper2.c b/tools/ioemu/target-i386-dm/helper2.c index 637a3eb4a4..46cdc54787 100644 --- a/tools/ioemu/target-i386-dm/helper2.c +++ b/tools/ioemu/target-i386-dm/helper2.c @@ -495,8 +495,12 @@ void cpu_ioreq_xchg(CPUState *env, ioreq_t *req) void __handle_ioreq(CPUState *env, ioreq_t *req) { - if (!req->data_is_ptr && (req->dir == IOREQ_WRITE) && (req->size != sizeof(req->data))) - req->data &= (1UL << (8 * req->size)) - 1; + if (!req->data_is_ptr && (req->dir == IOREQ_WRITE)) { + /* Clamp data operand to size of a long. */ + if (req->size < sizeof(long)) + req->data &= (1UL << (8 * req->size)) - 1; + req->data = (unsigned long)req->data; + } switch (req->type) { case IOREQ_TYPE_PIO: -- 2.30.2